             package com.java.diagnostics.visualizer.recommender.memory;
             
             import com.java.diagnostics.visualizer.data.AggregateData;
             import com.java.diagnostics.visualizer.data.DataPoint;
             import com.java.diagnostics.visualizer.data.TupleData;
             import com.java.diagnostics.visualizer.parser.vgc.constants.VGCAxes;
             import com.java.diagnostics.visualizer.parser.vgc.constants.VGCGCScopes;
             import com.java.diagnostics.visualizer.recommender.Recommendation;
             import com.java.diagnostics.visualizer.recommender.RecommendationBase;
             import com.java.diagnostics.visualizer.recommender.util.Messages;
             import com.java.diagnostics.visualizer.recommender.util.RecommendationLabels;
             import java.text.MessageFormat;
             
             public class CalculateMemoryProperties
               extends RecommendationBase
               implements Recommendation
             {
               protected String label;
               protected int identifier;
               
               public void recommend(AggregateData data)
               {
                 TupleData scopeRecord = data.getTupleData("VGCLabels.gc.scopes");
                 TupleData fragmentation = data.getTupleData("VGCLabels.unusable.heap");
                 if ((fragmentation != null) && (!fragmentation.isEmpty())) {
                   addToSummary(data, makeLabel(this.label, MessageFormat.format(
                     RecommendationLabels.MEAN_UNUSABLE_HEAP, 
                     new Object[] { VGCAxes.MB })), 
                     new Double(fragmentation.getMeanY(VGCAxes.MB)));
                 }
                 
                 TupleData bytesFlipped = data.getTupleData("VGCLabels.amount.flipped");
                 TupleData bytesTenured = data.getTupleData("VGCLabels.amount.tenured");
                 
                 TupleData calculatedLiveData = data
                   .getTupleData("VGCLabels.live.normal.heap.after.gc");
                 
                 if (calculatedLiveData != null)
                 {
                   DataPoint[] liveData = calculatedLiveData.getDataPoints();
                   
                   DataPoint[] flipped = (DataPoint[])null;
                   if (bytesFlipped != null) {
                     flipped = bytesFlipped.getDataPoints();
                   }
                   DataPoint[] tenured = (DataPoint[])null;
                   if (bytesTenured != null) {
                     tenured = bytesTenured.getDataPoints();
                   }
                   
                   double totalTenured = 0.0D;
                   double totalFlipped = 0.0D;
                   
                   if (bytesFlipped != null) {
                     for (int i = 0; i < flipped.length; i++) {
                       if (isCollectionOfGivenScope(scopeRecord, flipped[i], 
                         this.identifier)) {
                         totalFlipped += flipped[i].getY(VGCAxes.MB);
                       }
                     }
                   }
                   
                   if (bytesTenured != null) {
                     for (int i = 0; i < tenured.length; i++) {
                       if (isCollectionOfGivenScope(scopeRecord, tenured[i], 
                         this.identifier)) {
                         totalTenured += tenured[i].getY(VGCAxes.MB);
                       }
                     }
                   }
                   
                   if (liveData != null) {
                     for (int i = 0; i < liveData.length; i++) {
                       if ((VGCGCScopes.GLOBAL_INT == this.identifier) && 
                         (isCollectionOfGivenScope(scopeRecord, 
                         liveData[i], this.identifier))) {
                         totalTenured += liveData[i].getY(VGCAxes.MB);
                       }
                     }
                   }
                   
                   if ((bytesFlipped != null) && (VGCGCScopes.GLOBAL_INT != this.identifier)) {
                     addToSummary(data, makeLabel(this.label, Messages.getString(
                       "total.flipped", new Object[] {
                       VGCAxes.MB })), new Double(totalFlipped));
                   }
                   
                   if ((bytesTenured != null) && (isGenerational(data))) {
                     addToSummary(data, makeLabel(this.label, Messages.getString(
                       "total.amount.tenured", 
                       new Object[] { VGCAxes.MB })), 
                       new Double(totalTenured));
                   }
                 }
               }
             }


